#include"progressbar.h" 
   double gtotal = 1024.0;
   double speed = 1.0;
   typedef void (*callback_t)(double,double);
   
double SpeedFolate(double start,double range)
{
  int int_range = (int)range;
  return start + int_range + (range - int_range);
}
  
  //cb:回调函数，易维护，只需修改一处
void DownLoad(double total,callback_t cb)
{
  
  double curr = 0.0;
  while(1)
  {
    if(curr > total)//防止curr >= total 但是进度条没有刷新，卡在99.3% 99.7% 实际上已达总量上限
    {
      cb(total,curr);//更新进度,按照下载进度，进行更新进度条
      break;
    }
    cb(total,curr);//更新进度,按照下载进度，进行更新进度条   
    curr += SpeedFolate(speed,4.3);
    usleep(3000);
  }                                                                                                                                                                                                                                
}
  

int main()
{
    srand(time(NULL));
    printf("总大小为：10000.0MB\n");
    DownLoad(10000.0,FlushProcess);  
    return 0;
}

